import Vue from "vue";
import VueRouter from "vue-router";
// import Home from '../views/Home.vue';
// import LongStrip from '../views/LongStrip.vue';
import Login from "../views/Login.vue";
import AMap from "../views/AMap.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    meta: {
      isAuth: true,
    },
    redirect: "/cockpit4",
  },
  {
    path: "/Login",
    name: "Login",
    meta: {
      isAuth: false,
    },
    component: Login,
  },
  {
    path: "/amap",
    name: "amap",
    meta: {
      isAuth: false,
    },
    component: AMap,
  },
  {
    path: "/cockpit",
    name: "Cockpit",
    meta: {
      isAuth: true,
    },
    component: () => import("@/views/pages/cockpit.vue"),
  },
  {
    path: "/cockpit2",
    name: "Cockpit2",
    meta: {
      isAuth: true,
    },
    component: () => import("@/views/pages/cockpit2.vue"),
  },
  {
    path: "/cockpit3",
    name: "Cockpit3",
    meta: {
      isAuth: true,
    },
    component: () => import("@/views/pages/cockpit3.vue"),
  },
  {
    path: "/cockpit4",
    name: "Cockpit4",
    meta: {
      isAuth: true,
    },
    component: () => import("@/views/pages/cockpit4.vue"),
  },
];

const router = new VueRouter({
  mode: "",
  base: process.env.VUE_APP_ROUTER_BASE_URL,
  routes,
});

router.beforeEach((to, from, next) => {
  // const username = localStorage.getItem('zhszjjjsc_username');
  // const password = localStorage.getItem('zhszjjjsc_password');
  // if (to.matched.some(route => route.meta && route.meta.isAuth)) {
  // if (!username || !password) { // 鉴权
  //     next({
  //         path: '/Login', // 重定向到登录页
  //         query: { redirect: to.fullPath } // 'to.fullPath'跳转到登录之前页面的路径
  //     });
  // } else {
  // next(); // 继续跳转
  // }
  // } else {
  next(); // 继续跳转
  // }
});

export default router;
